<!--
 * @Author: coman
 * @LastEditors: coman
 * @Date: 2020-06-18 21:12:02
 * @motto: No pain,No gain
 * @LastEditTime: 2020-06-18 21:23:00
--> 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 随机生成一个五位以内的数，然后输出该数共有多少位，每位分别是什么。 */
        function countNum(str){
           var str1 = str.split("");
           console.log(str+"的位数是:"+str1.length+"分别是");
           str1.forEach(function(value,index){
                console.log(value);
                
           })
        }
        function getRandomNum(){
            return parseInt (Math.random()*10000);
        }
        num=getRandomNum();
        
        str=num.toString();
        
        countNum(str);
        
    </script>
</body>
</html>